//
//  ApplicationAssembly.swift
//  RemoteService
//
//  Created by Longxiang Guo (QXQ4633) on 2021/5/27.
//

import Foundation
import Swinject

typealias ApplicationAssembly = WatchApplicationAssembly


class WatchApplicationAssembly {
    
    private static let container = Container()
 
    static func Install() {
 
        container.register(WCSessionWrapperProtocol.self) { _ in
            return WCSessionWrapper()
        }

        container.register(WCServiceProtocol.self) { r in
            return WCService(
                session: r.resolve(WCSessionWrapperProtocol.self)!
            )
        }

        container.register(FileManagerProtocol.self) { r in
            return FileManager.default
        }

        container.register(WatchLogger.self) { r in
            return WatchLogger(
                wcService: r.resolve(WCServiceProtocol.self)!,
                fileManager: r.resolve(FileManagerProtocol.self)!
            )
        }
    }
    
    static func resolve<Service>(_ serviceType: Service.Type) -> Service {
       return container.resolve(serviceType)!
    }
    
}
